<?php
/**
* 客服类
*/ 
namespace app\adm\model;
use think\Db;
class Customs
{
    /**
    *常见问题
    */
    public function proTitle()
    {
        $proTitle=Db::name('Problem')->select();
        if($proTitle){
            return $proTitle;
        }else{
            return false;
        }
    }
    /**
    * 问题答案
    */
    public function proContent($problemId)
    {
        $where['problemId']=$problemId;
        $proContent=Db::name('Problem')->where($where)->value('problemContent');
        if($proContent){
            return $proContent;            
        }else{
            return false;
        }
    }
    /**
    * 问题详情
    */
    public function proFind($problemId)
    {
        $where['problemId']=$problemId;
        $profind=Db::name('Problem')->where($where)->find();
        if($profind){
            return $profind;
        }else{
            return false;
        }
    }
    /**
    * 问题修改
    */
    public function proEdit($problemId,$problemTitle,$problemContent)
    {
        $where['problemId']=$problemId;
        $data['problemTitle']=$problemTitle;
        $data['problemContent']=$problemContent;
        $proEdit=Db::name('Problem')->where($where)->update($data);
        if($proEdit){
             return $proEdit;
        }else{
            return false;
        }
    }
    /**
    * 客服电话
    */
    public function custel($customId='',$phone='')
    {
        if($customId=='' && $phone==''){
            $custels=Db::name('custom')->find();
            if($custels){
                return $custels;
            }else{
                return false;
            }
        }else{
            $where['customId']=$customId;
            $data['phone']=$phone;
            $custelup=Db::name('custom')->where($where)->update($data);
            if($custelup){
                return true;
            }else{
                return false;
            }
        }
    }
    /**
    * 反馈意见
    */
    public function suggest($suggestsId='')
    {
        if($suggestsId==''){
            $suggestPage=Db::name('suggest')->paginate(10);
            $suggestList=$suggestPage->all();
            foreach($suggestList as $k=>$v){
                $where['userid']=$v['userid'];
                $suggestList[$k]['nickname']=Db::name('user')->where($where)->value('nickname');
            }
            $suggests['list']=$suggestList;
            $suggests['page']=$suggestPage;
            if($suggests){
                return $suggests;
            }else{
                return false;
            }
        }else{
            $wheredel['suggestsId']=$suggestsId;
            $suggestDel=Db::name('suggest')->where($wheredel)->delete();
            if($suggestDel){
                return true;
            }else{
                return false;
            }
        }
    } 
}